﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
//using System.Xml.Linq;
using KPIS.Utils;
using KPIS.GERP.GHRMS.BLL;
using KPIS.GERP.GHRMS.IBLL;
using KPIS.GERP.GHRMS.MODEL;
using KPIS.GERP.GHRMS.APP.Classes;
using _WebShared.Classes;
using System.IO;
using System.Collections.Generic;
using Telerik.Web.UI;

namespace KPIS.GERP.GHRMS.APP.App_UI.Forms
{
    public partial class DialogQualification : System.Web.UI.Page
    {
        private IMasEducationQualificationBLL BLL = new MasEducationQualificationBLL();
        protected void Page_Load(object sender, EventArgs e)
        {
            IncludeJava();
            if (!IsPostBack)
            {
                LoadDataGrid();
            }
           // page.Attbliess.add('', 'javasct:funcitonJavasctip());
            // txtOldSalary.Attributes.Add("onkeypress", "return isNumberKeyDot(event)");
           // Page.Attributes.Add("", "javasct:funcitonJavasctip()");
        }

        public void LoadDataGrid()
        {
            //IList<MasEducationQualificationInfo> InfoList = BLL.ListEducationQualifications("");
            DataSet ds = BLL.LoadEducationQualifications((int?)null, (int?)null, "");
            DataTable dt = ds.Tables[0];
            RadGrid1.DataSource = dt;
            RadGrid1.DataBind();
        }
        public void IncludeJava()
        {
            HtmlGenericControl script = new HtmlGenericControl();
            script.TagName = "script";
            script.Attributes.Add("type", "text/javascript");
            script.Attributes.Add("src", "../../Scripts/jsfunction.js");
            Page.Header.Controls.Add(script);
        }
        protected void RadGrid1_ItemCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)
        {
            LoadDataGrid();
        }

        protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
        {
              
        }


        protected void btnOK_Click(object sender, EventArgs e)
        {
            try
            {
                CheckBox cb1;
                ArrayList arr = new ArrayList();
                foreach (GridItem item in this.RadGrid1.Items)
                {
                    cb1 = (CheckBox)item.Cells[2].FindControl("cb1");
                    if (cb1.Checked == true)
                    {
                        arr.Add(new ListItem(item.Cells[4].Text, item.OwnerTableView.DataKeyValues[item.ItemIndex]["edu_qual_seq"].ToString()));
                    }
                   
                }

                Session["arr"] = arr;
            //    string[] strArray = arr.ToArray(typeof(string)) as string[];
            //    string str = string.Join(",", strArray);
                string str = "1";
                ClientScript.RegisterClientScriptBlock(this.GetType(), "Onload", "<SCRIPT>windowReturn('" + str + "');</SCRIPT>");


               // Session["arr"] = str;


               // string str = string.Join(",", arr.ToArray(typeof(string)) as string[]);

                //string strscript = "<script language=javascript>window.top.close();</script>";
                //if ((!ClientScript.IsStartupScriptRegistered("clientScript")))
                //{
                //    ClientScript.RegisterStartupScript(Page.GetType(), "clientScript", strscript);
                //}
                //Utils.Web.CloseWindow(this);
                //self.close();
                //string strscript = "<script language=javascript>self.opener=this; self.open('','_parent',''); self.close();</script>";
                //if ((!ClientScript.IsStartupScriptRegistered("clientScript")))
                //{
                //    ClientScript.RegisterStartupScript(Page.GetType(), "clientScript", strscript);
                //}

            }
            catch (Exception ex)
            {

            }
        }
    }
}
